from flask import Flask,render_template,redirect,request,session

app = Flask(__name__)
app.secret_key = 'dafdfadfadfaf'
app.debug = True 

@app.before_request
def check_login():
    if request.path == '/login':
        return None 
    user = session.get('user_info')
    if not user:
        return redirect('/login')
    return "检查登陆"

@app.route("/login",methods=['GET','POST'])
def login():
    print("视图函数x1")
    return "视图函数x1"

@app.route("/index",methods=['GET','POST'])
def index():
    print("视图函数x2")
    return "视图函数x2"

if __name__=="__main__":
    app.__call__
    app.run()